package com.wc.AlgoOJ_train.train2_DP训练.c3.DPE005;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

/**
 * @Author congge
 * @Date 2024/1/13 1:07
 * @description 光头强的背包2
 * 转换思想，把价值和当做背包容量
 * 求最大价值的最小容量
 * <p>
 * http://43.138.190.70:8888/p/DPE005
 */
public class Main {
    static int maxN = (int) 1e5 + 7;
    static int[] ws = new int[100 + 7];
    static int[] vs = new int[100 + 7];
    // dp[i] 表示当价值为i的时候，最小重量
    static int[] dp = new int[maxN];
    static int n, m;
    static FastReader sc = new FastReader();
    static PrintWriter out = new PrintWriter(System.out);

    public static void main(String[] args) {
        n = sc.nextInt();
        m = sc.nextInt();
        int maxV = 0;
        // 因为是最小重量，所以可以要先填充最大重量
        Arrays.fill(dp, (int) 1e9 + 10);
        for (int i = 1; i <= n; i++) {
            ws[i] = sc.nextInt();
            vs[i] = sc.nextInt();
            maxV += vs[i];
        }
        dp[0] = 0;
        for (int i = 1; i <= n; i++) {
            for (int j = maxV; j >= vs[i]; j--) {
                dp[j] = Math.min(dp[j], dp[j - vs[i]] + ws[i]);
            }
        }
        // 这里可以二分优化，但是没有必要，前面已经是n的复杂度了
        for (int i = maxV; i >= 0; i--) {
            if (dp[i] <= m) {
                out.println(i);
                break;
            }
        }
        out.flush();
    }
}

class FastReader {
    StringTokenizer st;
    BufferedReader br;

    FastReader() {
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    String next() {
        while (st == null || !st.hasMoreElements()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }

    int nextInt() {
        return Integer.parseInt(next());
    }

    String nextLine() {
        String s = "";
        try {
            s = br.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return s;
    }

    long nextLong() {
        return Long.parseLong(next());
    }

    double nextDouble() {
        return Double.parseDouble(next());
    }
}
